********************************************************************************
*                                                                              *
*           WHY DO PEOPLE USE INFORMAL JUSTICE? REPLICATION (JEPS)             *
*                                                                              *
********************************************************************************

    

* load the data and define results paths (fill in with your own URL)    
use "/Users/krzysztofkrakowski/Dropbox/Kosovo project/2_Orders/1_Data/asian_barometer.dta", clear
global PathTab = "/Users/krzysztofkrakowski/Dropbox/Kosovo project/2_Orders/4_Writing/z_tables/to_edit/"



* create reliance on customary justice measures (actual - first line; and hypothetical - second line)
recode q71a -1=. 1/3=1 4=0 7/9=., gen(customary)
recode q71a -1=. 1/2=. 3=1 4=0 7/9=., gen(customary_control)


* create resourcelessness measure
recode se14a -1/0=. 1/2= 0 3=1 7/9=., gen(resourceless)

* create mistrust in the justice system measure (inefficiency proxy)
recode q14 -1=. 1/2=0 3/4=1  7/9=., gen(mistrust_police)
recode q8 -1=. 1/2=0 3/4=1 7/9=., gen(mistrust_courts)

egen mistrust_law = rowmean(mistrust_courts mistrust_police)

* create conventions measure
egen area = concat(region level)
bysort area: egen customary_mean=mean(customary)
bysort area: egen customary_cntr_mean=mean(customary_control)


* standardize and label
zval customary customary_control resourceless mistrust_law customary_mean customary_cntr_mean  
label variable z_resourceless "Resourcelessness"
label variable z_mistrust_law "Inefficiency"
label variable z_customary_mean "Conventions"
label variable z_customary_cntr_mean "Conventions"


* recode controls (no answers recoded as missing values)
recode se3_2 -1=.
recode se2  -1=.
recode se4  -1=.
recode se6  -1=.
recode se5  -1=.
recode se7  -1=.
recode se8a -1=.



* Table A11
eststo clear
eststo Informal_Justice_Behavior: reghdfe z_customary z_resourceless z_mistrust_law z_customary_mean se3_2 i.se2 i.se4 i.se6 i.se5 se7 se8a, abs(region year)
estadd local controls = "Yes"
eststo Informal_Justice_Preference: reghdfe z_customary_control z_resourceless z_mistrust_law z_customary_cntr_mean se3_2 i.se2 i.se4 i.se6 i.se5 se7 se8a, abs(region year)
estadd local controls = "Yes"
esttab Informal_Justice_Behavior Informal_Justice_Preference using "${PathTab}TableA11.tex", b(3) se(3) star(* 0.1 ** 0.05 *** 0.01) drop(_cons) stats(controls r2 N, labels("Controls" "R-squared" "N")) label nodepvar mtitles title("Determinants of Informal Justice (Asianbarometer Data)") replace nonotes postfoot(" ")
